// MfcDllForNsis.cpp : Defines the entry point for the DLL application.
//

#include "stdafx.h"
#include "MfcDllForNsis.h"
#include "ListDlg.h"

using namespace std;

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

// The one and only application object
CWinApp theApp;

CListDlg* g_pListDlg = NULL;

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
	int nRetCode = 0;

	// initialize MFC and print and error on failure
	if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
	{
		// TODO: change error code to suit your needs
		_tprintf(_T("Fatal Error: MFC initialization failed\n"));
		nRetCode = 1;
	}
	else
	{
		// TODO: code your application's behavior here.
	}

	return nRetCode;
}

MFCDLLFORNSIS_API void ShowListDlg(int iHwndParent)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());

	HWND hWndParent = (HWND)iHwndParent;
	CWnd* pWndParent = CWnd::FromHandle(hWndParent);
	if (pWndParent)
	{
		if (g_pListDlg == NULL)
		{
			g_pListDlg = new CListDlg;
			g_pListDlg->Create(IDD_DLG_LIST, pWndParent);
		}
		if (g_pListDlg)
		{
			g_pListDlg->ShowWindow(SW_SHOW);
			g_pListDlg->SetActiveWindow();
		}
	}
}

MFCDLLFORNSIS_API void FreeDlgResource()
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	if (g_pListDlg)
	{
		g_pListDlg->ClearDatas();
	}
}

MFCDLLFORNSIS_API void SetAllChecked()
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	if (g_pListDlg)
	{
		g_pListDlg->SetAllChecked(true);
	}
}

MFCDLLFORNSIS_API void SetAllNotChecked()
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	if (g_pListDlg)
	{
		g_pListDlg->SetAllChecked(false);
	}
}